package com.fish.web.passport;

import java.util.ArrayList;
import java.util.List;

import com.fish.common.constant.QueryPage;
import com.fish.common.web.BaseAction;
import com.fish.product.po.PerformTarget;
import com.fish.service.passport.PerformTargetService;
import com.fish.sight.po.Sight;

/**
 * 设备管理
 * 
 * @author clj
 * 
 */
public class PerformTargetAction extends BaseAction {
	private static final long serialVersionUID = 3470439229072020921L;
	private PerformTarget performTarget = new PerformTarget();
	private PerformTargetService performTargetService;
	private List<PerformTarget> performTargetList = new ArrayList<PerformTarget>();
	private QueryPage queryPage = new QueryPage();

	public String edit() {
		if (this.performTarget.getTargetId() == null) {
			this.performTargetService.addPerformTarget(performTarget);
		} else {
			this.performTargetService.updatePerformTarget(performTarget);
		}
		return SUCCESS;
	}

	public String delete() {
		if (this.performTarget.getTargetId()!=null) {
			this.performTargetService.deleteTargetById(performTarget.getTargetId());
		}
		return performTargetList();
	}

	public String goToEdit() {
		if (this.performTarget != null) {
			this.performTarget = this.performTargetService.getPerformTargetById(this.performTarget.getTargetId());
		}
		return SUCCESS;
	}

	public String performTargetList() {
		Long count = performTargetService.queryPerformTargetCountByObject(performTarget);
		if(count > 0){
			queryPage = new QueryPage(count, 2, queryPage.getCurPage());
		}		
		performTargetList = performTargetService.queryPerformTargetByObject(performTarget,queryPage);
		return SUCCESS;
	}

	public PerformTarget getPerformTarget() {
		return performTarget;
	}

	public void setPerformTarget(PerformTarget performTarget) {
		this.performTarget = performTarget;
	}

	public PerformTargetService getPerformTargetService() {
		return performTargetService;
	}

	public void setPerformTargetService(PerformTargetService performTargetService) {
		this.performTargetService = performTargetService;
	}

	public List<PerformTarget> getPerformTargetList() {
		return performTargetList;
	}

	public void setPerformTargetList(List<PerformTarget> performTargetList) {
		this.performTargetList = performTargetList;
	}

	public QueryPage getQueryPage() {
		return queryPage;
	}

	public void setQueryPage(QueryPage queryPage) {
		this.queryPage = queryPage;
	}

}
